import Sport from "../../utils/sport"

export default class RecommonedMatchModel {
  // 联赛名字
  leagueName: string

  // 比赛Id
  mathchId: number
  // 比赛日期 08-18
  matchDate: string
  // 比赛时间 21:30
  matchTime: string
  // 比赛类型 1:足球 2:篮球
  sportId: number
  // 是否有比赛动画
  hasAnimation: boolean
  // 是否有比赛视频
  hasVideo: boolean
  // 是否是滚球
  isIot: boolean

  // 主队队名
  homeTeamName: string
  // 客队队名
  homeIconUrl: string
  // 主队比分
  homeScore: string

  // 主队队名
  guestTeamName: string
  // 客队队名
  guestIconUrl: string
  // 客队比分
  guestScore: string

  constructor(oldItem) {
    this.leagueName = oldItem.leagueName
    this.sportId = oldItem.sportId
    this.mathchId = oldItem.k
    let iotStr = oldItem["iot"]
    if (iotStr === "iot") {
      this.isIot = true
    } else {
      this.isIot = false
    }

    let iArr = oldItem.i
    this.homeTeamName = iArr[0]
    this.guestTeamName = iArr[1]
    this.homeScore = iArr[10]
    this.guestScore = iArr[11]

    this.homeIconUrl =
      Sport.SportIconBaseUrl + this.sportId + "?kw=" + encodeURIComponent(this.homeTeamName)
    this.guestIconUrl =
      Sport.SportIconBaseUrl + this.sportId + "?kw=" + encodeURIComponent(this.guestTeamName)
  }
}
